﻿$.fn.extend({
    postForm: function (callback) {
        $.post($(this).attr("action"), $(this).serialize(), callback);
    }
});



$.extend({
    handleAjaxCallback: function (d) {
        if (d.error) {
            alert(d.error); return;
        }
        if (d.message) {
            alert(d.message);
        }
        if (d.url) {
            window.location.href = d.url;
        }
    }
});

$(function () {
    $("a[ajax]").click(function () {
        $.post($(this).attr("href"), {}, function (d) {
            $.handleAjaxCallback(d);
        });
    });
});